<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/pages/reg.css" />
		<style>
			body {
			background-color: #fff;
		}

		.mui-content {
			background-color: #fff;
		}
	</style>
	</head>

	<body>
		<div id="app" class="content">
			<div class="logo">
				修改密码
			</div>
			<form>
				<div class="itemClass">
					<input type="password" placeholder="输入旧密码" v-model="oldUserPwd" class="mui-input-clear mui-input">
				</div>

				<div class="itemClass">
					<input type="password" placeholder="输入新密码" v-model="userPwd" class="mui-input-clear mui-input">
				</div>
				<div class="itemClass">
					<input type="password" placeholder="确认新密码" v-model="newUserPwd" class="mui-input-clear mui-input">
				</div>
			</form>
			<div class="login" @click="loginTap">完成</div>
		</div>
		<script src="../js/Width.js"></script>
		<script src="../js/mui.min.js"></script>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/app.js"></script>
		<script src="../js/Util.js"></script>
		<script src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>
		<script>
			mui.plusReady(function() {
				if (!mui.os.android) {
					FastClick.attach(document.body);
				}
				plus.webview.currentWebview().setStyle({
					softinputMode: "adjustResize"
				});
			})

			var app = new Vue({
				el: "#app",
				data: {
					num: 0,
					oldUserPwd: '',
					userPwd: '',
					newUserPwd: ''
				},
				methods: {
					loginTap: function() {
						var that = this
						if (!that.oldUserPwd || !that.userPwd || !that.newUserPwd) {
							mui.toast('请填写完整')
							return
						}

						if (that.userPwd == that.newUserPwd && Util.checkPassword(that.newUserPwd)) {
							plus.nativeUI.showWaiting('提交中', {
								width: '100px',
								height: '100px'
							});
							 that.UpdatePassword()
						} else {
							mui.toast('两次密码不一致')
						}
					},
					UpdatePassword: function() {
						var that = this
						mui.post(Util.HTTP + 'api/Users/UpdatePassword', {
							userID: Util.getState('$state').userID,
							userPwd: that.oldUserPwd,
							newUserPwd: that.newUserPwd
						}, function(res) {
							if (res.code == 1001) {
								plus.nativeUI.closeWaiting();
								mui.toast('修改成功')
								setTimeout(function() {
									mui.back()
								}, 1000)
							} else {
								mui.toast(res.message)
							}
						})
					}
				},
			})
		</script>
	</body>

</html>
